{extend name="Public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugs/board/board.min.css">
{/block}
{block name="body"}
<div class="main-box clearfix">
	<header class="main-box-header clearfix">
		<div class="pull-left">
			<h2>编辑钩子</h2>
		</div>
	</header>

	<div class="main-box-body clearfix">
		<form action="{:U('Addons/updateHook')}" method="post" class="form form-horizontal">
			<div class="form-group">
				<label class="col-lg-2 control-label">钩子名称</label>
				<div class="col-lg-6">
					<input type="text" class="form-control" name="name" value="{$info.name|default=''}">
					<span class="help-block">（钩子名称,需要在程序中先添加钩子，否则无效）</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-lg-2 control-label">钩子描述</label>
				<div class="col-lg-6">
					<input type="text" class="form-control" name="description" value="{$info.description|default=''}">
					<span class="help-block">（钩子的描述信息{$info.type_text}）</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-lg-2 control-label">钩子类型</label>
				<div class="col-lg-2">
					<select name="type" id="type" class="form-control">
						<option value="1">视图</option>
						<option value="2" {eq name="info.type" value="2"}selected{/eq}>控制器</option>
					</select>
				</div>
			</div>

			<div class="form-group">
				<label class="col-lg-2 control-label">钩子挂载的插件排序 </label>
				<div class="col-lg-10 boards" id="field_group_sort">
					<div class="board panel panel-info">
						<div class="panel-heading">钩子挂载的插件排序</div>
						<div class="panel-body">
							<div class="board-list" data-group="{$key}">
							{if condition="$info.addons eq ''"}
								<div class="board-item">
									<span>没有钩子,无法进行排序</span>
								</div>
							{else /}
								{volist name=":parse_field_attr($info['addons'])" id="vo"}
									<div class="board-item">
										<span>{$vo}</span>
										<input type="hidden" name="addons[]" value="{$vo}"/>
									</div>
								{/volist}
							{/if}
							</div>
						</div>
					</div>
				<span class="help-block"></span>
				</div>				
			</div>
 
		<div class="form-group">
			<div class="col-lg-offset-2 col-lg-10">
				<input type="hidden" name="id" value="{$info.id|default=''}">
				<button class="btn btn-success submit-btn ajax-post" type="submit" target-form="form-horizontal">确 定</button>
				<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
			</div>
		</div>
	</form>
</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/js/droppable.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/board/board.min.js"></script>
<script type="text/javascript">
$(function(){
	$('.form-group #field_sort').boards();
	$('.form-group #field_group_sort').boards({
		drop: function(e){
			var group = e.target.closest('.board').find('.board-list').attr('data-group');
			e.element.find('input').attr('name','addons[]')
		}
	})
})
</script>
{/block}